using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Main : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        NetManager.AddEventListener(NetManager.NetEvent.ConnectSucc,OnEventConnectSucc);
        NetManager.AddEventListener(NetManager.NetEvent.ConnectFail,OnEventConnectFail);
        NetManager.AddEventListener(NetManager.NetEvent.Close,OnEventConnectClose);
        
        NetManager.Connect("127.0.0.1", 8888);

        PanelManager.Instance.Open<TestPanel>();
        // protogen.exe -i:proto\MsgPing.proto -o:cs\MsgPing.cs -ns:PBMessage
        // protogen.exe -i:proto\MsgPong.proto -o:cs\MsgPong.cs -ns:PBMessage
    }

    private void Update()
    {
        NetManager.Update();
    }
    
    private void OnEventConnectSucc(string err)
    {
        Debug.Log("链接成功");
    }
    private void OnEventConnectFail(string err)
    {
        Debug.Log("链接失败");
    }
    
    private void OnEventConnectClose(string err)
    {
        Debug.Log("断开链接");
    }
}
